import 'package:connectivity/connectivity.dart';

class NetWifiStatusUtil {
  static isConnected() async {
    var connectivityResult = await (Connectivity().checkConnectivity());
    return connectivityResult != ConnectivityResult.none;
  }

  static isWifi() async {
    bool isWifi = false;
    var connectivityResult = await (Connectivity().checkConnectivity());
    if (connectivityResult == ConnectivityResult.mobile) {
// 网络类型为移动网络
      isWifi = false;
    } else if (connectivityResult == ConnectivityResult.wifi) {
// 网络类型为WIFI
      isWifi = true;
    }

    return isWifi;
  }
}

/*Future<bool> isConnected() async {
  var connectivityResult = await (Connectivity().checkConnectivity());
  return connectivityResult != ConnectivityResult.none;
}

Future<bool> isWifi() async {
  bool isWifi = false;
  var connectivityResult = await (Connectivity().checkConnectivity());
  if (connectivityResult == ConnectivityResult.mobile) {
// 网络类型为移动网络
    isWifi = false;
  } else if (connectivityResult == ConnectivityResult.wifi) {
// 网络类型为WIFI
    isWifi = true;
  }

  return isWifi;
}*/
